#include <bits/stdc++.h>
using namespace std;
using ll = long long;
using pii = pair<int, int>;
using pll = pair<ll, ll>;
#define rep(i, a, b) for (int i = (a); i <= (b); i++)
#define per(i, a, b) for (int i = (a); i >= (b); i--)
#define endl '\n'
const int N = 2e5 + 5;
const int MOD = 1e9 + 7;
int n, m;
ll a[35], b[5];
ll sum[1 << 24];
int dp[1 << 24];
bool check(ll x) {
  rep(i, 1, m) if (b[i] == x) return false;
  return true;
}
inline int lowbit(int x) { return x & -x; }
int main() {
  ios::sync_with_stdio(0), cin.tie(0), cout.tie(0);
  cin >> n;
  rep(i, 0, n - 1) cin >> a[i];
  cin >> m;
  rep(i, 1, m) cin >> b[i];
  rep(i, 0, n - 1) sum[1 << i] = a[i];
  int mx = (1 << n) - 1;
  rep(s, 0, mx) {
    int x = s & -s;
    sum[s] = sum[s ^ x] + sum[x];
    if (!check(sum[s])) continue;
    if (x == s) {
      dp[s] = 1;
      continue;
    }
    for (int i = s; i; i -= lowbit(i)) {
      int t = s ^ lowbit(i);
      dp[s] = (dp[s] + dp[t]) % MOD;
    }
  }
  cout << dp[mx];
  return 0;
}